package com.woniuxy.ticketcinema.controller;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.woniuxy.ticketcinema.entity.Schedule_seat;
import com.woniuxy.ticketcinema.entity.Seat;
import com.woniuxy.ticketcinema.service.SeatService;
import com.woniuxy.ticketcommon.entity.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yanqiwei
 * @since 2021-02-20
 */
@Slf4j
@RestController
@RequestMapping("/seat")
public class SeatController {

    @Autowired
    private SeatService seatService;

    /**
     * 修改该排片订单下的座位出售状态
     * @param ids      座位id
     * @param status  设置状态
     * @return        操作结果
     */
    @PutMapping("/updateSeatStatus")
    public ResponseResult updateseatstatus(@RequestParam("ids") List<String> ids, @RequestParam("status") String status){

        List<Seat> seats = seatService.listByIds(ids);
        seats.forEach(s->{s.setStatus(status);});
        seatService.updateBatchById(seats);
        log.info("更新状态");
        return ResponseResult.SUCCESS;
    }

}

